/*
 * File:   ChessMove.h
 * Author: crash
 *
 * Created on February 26, 2011, 10:26 PM
 */

#ifndef CHESSMOVE_H
#define	CHESSMOVE_H

#include "IMove.h"
#include "Typesfwd.h"
#include "ChessGame.h"
#include <boost/regex.hpp>

class ChessMove : public IMove
{
public:
    ChessMove(const std::string& str);

    void execute(model::ChessBoard &);

    void undo(model::ChessBoard &);
private:
    std::list<globals::movePtr> moves;
    static const boost::regex pattern;

    static const int PLACEPATTERN = 1, MOVEPATTERN = 6, INVALID = 12, PIECETYPE = PLACEPATTERN + 1, TEAM = PLACEPATTERN + 2, PLACECOL = PLACEPATTERN
            + 3, PLACEROW = PLACEPATTERN + 4, MOVEFROMCOL = MOVEPATTERN + 1, MOVEFROMROW = MOVEPATTERN + 2, MOVETOCOL = MOVEPATTERN + 3,
            MOVETOROW =	MOVEPATTERN + 4, MOVECAPTURE = MOVETOROW + 1;

    static globals::cPiece charToPiece(char, bool);

    class InvalidMove : public IMove
    {
    public:
        InvalidMove(const std::string& move);

        void execute(model::ChessBoard &);

        void undo(model::ChessBoard &);
    private:
        const std::string move;
    };

};

#endif	/* CHESSMOVE_H */

